{% extends "GitonomyWebsiteBundle::layout_profile.html.twig" %}

{% trans_default_domain 'profile_information' %}

{% block title 'page.title'|trans %}

{% set local_navigation = 'information' %}

{% block profile_content %}
    <div id="content">
        <form class="form-horizontal" method="POST" action="{{ path('profile_saveInformation') }}">
            <legend>{{ 'title.information'|trans }}</legend>
            {{ form_rest(form) }}
            <div class="control-group">
                <div class="controls">
                    <button class="btn btn-success" type="submit"><i class="symbol">save</i> {{ 'form.information.submit'|trans }}</button>
                </div>
            </div>
        </form>

        <form class="form" action="{{ path('profile_createEmail') }}" method="POST" id="user_email">
            <legend>{{ 'title.emails'|trans }}</legend>
            {{ form_errors(form) }}
            <table class="bordered-table table table-striped">
                <thead>
                    <tr>
                        <th>{{ 'table.emails.column.email'|trans }}</th>
                        <th>{{ 'table.emails.column.is_default'|trans }}</th>
                        <th>{{ 'table.emails.column.is_active'|trans }}</th>
                        <th>{{ 'table.emails.column.actions'|trans }}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for email in user.emails %}
                        <tr id="email_{{ email.id }}">
                            <td>{{ email.email }}</td>
                            <td>{{ (email.isDefault == 1 ? 'table.emails.value.yes' : 'table.emails.value.no')|trans }}</td>
                            <td>{{ (email.isActive == 1 ? 'table.emails.value.yes' : 'table.emails.value.no')|trans }}</td>
                            <td>
                                <div class="btn-group pull-left">
                                    {% if not email.isDefault %}
                                        <a rel="tooltip" title="{{ 'button.default_email'|trans({'%email%': email.email}) }}" data-method="POST" href="{{ path('profile_defaultEmail', {id: email.id, token: token }) }}" class="btn btn-small email-default"><i class="icon-star"></i></a>
                                    {% endif %}
                                    {% if not email.isActive %}
                                        <a rel="tooltip" title="{{ 'button.activate_email'|trans({'%email%': email.email}) }}" data-method="POST" href="{{ path('profile_activateEmail', {'id': email.id, token: token }) }}" class="btn btn-small send-activation"><i class="icon-envelope"></i></a>
                                    {% endif %}
                                    {% if not email.isDefault %}
                                        <a rel="tooltip" title="{{ 'button.delete_email'|trans({'%email%': email.email}) }}" data-method="POST" data-confirm="{{ 'button.confirm.delete_email'|trans({'%email%': email.email}) }}" href="{{ path('profile_deleteEmail', {'id': email.id, token: token }) }}" class="btn btn-danger btn-small email-delete"><i class="icon-fire icon-white"></i></a>
                                    {% endif %}
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="3">
                            {{ form_widget(form_email.email) }}
                            {{ form_errors(form_email.email) }}
                        </td>
                        <td>
                            <div class="btn-group pull-right">
                                <button type="submit" class="btn btn-success"> <i class="symbol">plus </i>{{ 'form.new_mail.submit'|trans }}</button>
                            </div>
                        </td>
                    </tr>
                </tfoot>
            </table>
            {{ form_rest(form_email) }}
        </form>
    </div>
{% endblock %}
